package com.zhijian.warehouse.manage.controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import com.zhijian.response.annotation.Response;
import com.zhijian.util.page.Page;

import com.zhijian.warehouse.manage.entity.po.StoreLock;
import com.zhijian.warehouse.manage.service.StoreLockService;
import com.zhijian.warehouse.manage.entity.vo.request.StoreLockSearchVo;
import com.zhijian.warehouse.manage.entity.vo.request.StoreLockSaveOrUpdateVo;
import com.zhijian.warehouse.manage.entity.vo.response.StoreLockVo;

import lombok.extern.slf4j.Slf4j;
import java.util.List;

/**
 * 锁盘表 控制层
 * 
 * @author auto
 * @version 1.0
 * @date 2024-10-27 13:43:23
 */
@Slf4j
@Controller
@Api(tags = "锁盘表")
public class StoreLockController {

	@Autowired
    private StoreLockService service;
    
    /**
     * 新增
     *
     * @param param
     * @return
     */
    @Response
    @PostMapping("/store/lock")
    @ApiOperation("新增")
    public boolean insert(@RequestBody StoreLockSaveOrUpdateVo param) {
        log.info("{} - {}| insert info", this.getClass().getSimpleName(), param);
        return service.save(param);
    }

    /**
     * 删除
     *
     * @param id
     * @return
     */
    @Response
    @DeleteMapping("/store/lock/{id}")
    @ApiOperation("删除")
    public boolean delete(@PathVariable("id") Long id) {
        log.info("{} - {}| delete info", this.getClass().getSimpleName(), id);
        service.deleteById(id);
        return true;
    }

    /**
     * 修改
     *
     * @param id
     * @param param
     * @return
     */
    @Response
    @PutMapping("/store/lock/{id}")
    @ApiOperation("修改")
    public boolean update(@PathVariable("id") Long id, @RequestBody StoreLockSaveOrUpdateVo param) {
        log.info("{} - {}| update info, {}", this.getClass().getSimpleName(), id, param);
        param.setId(id);
        return service.modify(param);
    }

    /**
     * 根据id查询
     *
     * @param id
     * @return
     */
    @Response
    @GetMapping("/store/lock/{id}")
    @ApiOperation("根据id查询")
    public StoreLockVo selectById(@PathVariable("id") Long id) {
        log.info("{} - {}| query info", this.getClass().getSimpleName(), id);
        return service.selectVoById(id);
    }

    /**
     * 分页查询
     *
     * @param param
     * @return
     */
    @Response
    @PostMapping("/store/lock/page")
    @ApiOperation("分页查询")
    public Page<StoreLockVo> selectByCondition(@RequestBody(required = false) StoreLockSearchVo param) {
        if (param == null)
            param = StoreLockSearchVo.builder().build();
        log.info("{} - {}| query info", this.getClass().getSimpleName(), param);
        return service.selectPage(param);
    }

    /**
        * 列表查询
        *
        * @param param
        * @return
    */
    @Response
    @PostMapping("/store/lock/list")
    @ApiOperation("列表查询")
    public List<StoreLockVo> selectList(@RequestBody(required = false) StoreLockSearchVo param) {
            if (param == null)
            param = StoreLockSearchVo.builder().build();
            log.info("{} - {}| query info", this.getClass().getSimpleName(), param);
            return service.selectList(param);
        }

    /**
    * 批量删除
    *
    * @param idList
    * @return
    */
    @Response
    @DeleteMapping("/store/lock/list")
    @ApiOperation("批量删除")
    public boolean delete(@RequestBody(required = false) List<Long> idList) {
        log.info("{} - {}| delete info", this.getClass().getSimpleName(), idList);
        service.deleteByIdList(idList);
        return true;
     }
    /**
     * 修改
     *
     * @param warehouseId 仓库id
     * @param param
     * @return
     */
    @Response
    @PutMapping("/store/update/lock/{warehouseId}")
    @ApiOperation("锁盘 修改 仓库id type = 0 解盘 1 = 锁盘 当前登陆人id")
    public boolean updateLock(@PathVariable("warehouseId") Long warehouseId, @RequestBody StoreLockSaveOrUpdateVo param) {
        log.info("{} - {}| updateLock info, {}", this.getClass().getSimpleName(), warehouseId, param);
        param.setWarehouseId(warehouseId);
        return service.updateLock(param);
    }

    /**
     * 修改
     *
     * @param warehouseId 仓库id
     * @return
     */
    @Response
    @PutMapping("/store/select/lock/{warehouseId}")
    @ApiOperation("锁盘 修改 仓库id type = 0 解盘 1 = 锁盘")
    public StoreLockVo selectLock(@PathVariable("warehouseId") Long warehouseId) {
        log.info("{}| selectLock info, {}", this.getClass().getSimpleName(), warehouseId);
        return service.selectByWarehouseId(warehouseId);
    }
}